# -*-  coding: UTF-8  -*-

import wx, wx.xrc

class Window(object) :
    def CreateAttributes(self, attributes) :
        for attr in attributes :
            self.__dict__[attr] = self.XRCCTRL(attr)

    def XRCID(self, name) :
        return wx.xrc.XRCID(name)

    def XRCCTRL(self, name) :
        return wx.xrc.XRCCTRL(self, name)

class Frame(Window) :
    def __init__(self, parent, name, attributes = None) :
        pre = wx.PreFrame()
        xmlRes.LoadOnFrame(pre, parent, name)
        self.PostCreate(pre)
        if attributes :
            self.CreateAttributes(attributes)

class Dialog(Window) :
    def __init__(self, parent, name, attributes = None) :
        pre = wx.PreDialog()
        xmlRes.LoadOnDialog(pre, parent, name)
        self.PostCreate(pre)
        if attributes :
            self.CreateAttributes(attributes)

class Panel(Window) :
    def __init__(self, parent, name, attributes = None) :
        pre = wx.PrePanel()
        xmlRes.LoadOnPanel(pre, parent, name)
        self.PostCreate(pre)
        if attributes :
            self.CreateAttributes(attributes)

def Load(fname) :
    xmlRes.Load(fname)

# Load XRC
xmlRes = wx.xrc.EmptyXmlResource()
